<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>{$name}|{:config('app_name')}</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css">
    <link rel="stylesheet" href="__PUBLIC__/css/jquery.json-viewer.css">
    <link rel="stylesheet" href="__PUBLIC__/css/style.css">
</head>

<body>
    <div class="main">
        <div class="site-tree">
            <ul class="layui-tree">
                <notempty name="items">
                    <volist name="items" id="item">
                        <if condition="$item && !empty($item['title'])">
                            <li>
                                <h2>
                                    <a href="#item-{$item.id}">{$item.title}</a>
                                </h2>
                            </li>
                        </if>
                        <notempty name="item.request">
                            <volist name="item.request" id="vo">
                                <li>
                                    <a href="#api-{$vo.id}" data-id="{$vo.id}">
                                        <cite>
                                            <notin name="vo.id" value="$read">
                                                <span class="layui-badge-dot"></span>
                                                <else />
                                                <span class="layui-badge-dot none"></span>
                                            </notin> {$vo.name}
                                        </cite>
                                        <em>{$vo.method}</em>
                                    </a>
                                </li>
                            </volist>
                        </notempty>
                    </volist>
                </notempty>
            </ul>
        </div>
        <div class="site-content">
            <if condition="$edit_auth">
                <div class="layui-card">
                    <div class="layui-card-body">
                        <a href="{:url('category/add')}" class="layui-btn layui-btn-primary ajax-edit-api">
                            <i class="layui-icon">&#xe608;</i> 添加分类</a>
                        <a href="{:url('api/add')}" class="layui-btn layui-btn-primary ajax-edit-api">
                            <i class="layui-icon">&#xe608;</i> 添加Api</a>
                    </div>
                </div>
            </if>
            <div class="layui-card">
                <div class="layui-card-body">
                    <div class="site-h1">
                        <a href="#instruction">
                            <i class="layui-icon">&#xe600;</i>
                        </a> 文档说明
                    </div>
                    <div class="layui-form-item code">
                        {$remark|default=''|highLight|raw}
                    </div>
                    <hr>
                    <div>
                        {$script|default='无脚本'|raw}
                    </div>
                    <if condition="$is_public">
                        <hr>
                        <div style="color: #FF5722" class="code">
                            <i class="layui-icon">&#xe641;</i> <span>{$Request.domain}/share/{$id|encrypt}</span>
                        </div>
                    </if>
                </div>
            </div>
            <notempty name="items">
                <volist name="items" id="item">
                    <if condition="$item && !empty($item['title'])">
                        <div class="layui-card" id="item-{$item.id}">
                            <div class="layui-card-body">
                                <h1 class="site-h1">
                                    <i class="layui-icon">&#xe600;</i> {$item.title|highLight|raw}
                                    <if ($edit_auth) and ($is_self)>
                                        <div class="layui-btn-group right">
                                            <a href="{:url('category/edit',['id'=>$item['id']])}" class="layui-btn layui-btn-primary layui-btn-sm ajax-edit-api" title="编辑：{$item.title|default=''}">
                                                <i class="layui-icon">&#xe642;</i>
                                            </a>
                                            <a href="{:url('category/delete',['id'=>$item['id']])}" class="layui-btn layui-btn-primary layui-btn-sm ajax-delete" title="删除：{$item.title|default=''}">
                                                <i class="layui-icon">&#xe640;</i>
                                            </a>
                                        </div>
                                    </if>
                                </h1>
                                <p> {$item.remark|highLight|raw}</p>
                            </div>
                        </div>
                    </if>
                    <notempty name="item.request">
                        <volist name="item.request" id="vo">
                            <div id="api-{$vo.id}" class="layui-card">
                                <div class="layui-card-body">
                                    <div class="site-h1">
                                        <a href="#api-{$vo.id}">
                                            <i class="layui-icon">&#xe600;</i>
                                        </a> {$vo.name|highLight|raw}
                                        <if ($edit_auth) and ($is_self)>
                                            <div class="layui-btn-group right">
                                                <a href="{:url('response/add',['id'=>$vo['id']])}" class="layui-btn layui-btn-primary layui-btn-sm ajax-edit-api" title="添加响应内容">
                                                    <i class="layui-icon">&#xe654;</i>
                                                </a>
                                                <a href="{:url('edit',['id'=>$vo['id']])}" class="layui-btn layui-btn-primary layui-btn-sm ajax-edit-api" title="删除：{$vo.name}">
                                                    <i class="layui-icon">&#xe642;</i>
                                                </a>
                                                <a href="{:url('delete',['id'=>$vo['id']])}" class="layui-btn layui-btn-primary layui-btn-sm ajax-delete" title="编辑：{$vo.name}">
                                                    <i class="layui-icon">&#xe640;</i>
                                                </a>
                                            </div>
                                        </if>
                                    </div>
                                    <notempty name="vo.remark">
                                        <blockquote class="layui-elem-quote">
                                            {$vo.remark|highLight|raw}
                                        </blockquote>
                                    </notempty>
                                    <div class="layui-form layui-form-pane">
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">请求地址</label>
                                            <div class="layui-input-block">
                                                <div class="layui-input code" style="line-height: 38px">
                                                    {$vo.url|highLight|raw}
                                                </div>
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">请求方式</label>
                                            <div class="layui-input-block">
                                                <input type="text" value="{$vo.method}" readonly class="layui-input code">
                                            </div>
                                        </div>
                                        <php>$headers = json_decode($vo['headers'],true);</php>
                                        <notempty name="headers">
                                            <fieldset class="layui-elem-field layui-field-title">
                                                <legend> HEADERS</legend>
                                            </fieldset>
                                            <volist name="headers" id="header">
                                                <div class="layui-form-item">
                                                    <label class="layui-form-label">{$header.key|default=''}</label>
                                                    <div class="layui-input-block">
                                                        <input type="text" value="{$header.value|default=''}" readonly class="layui-input code">
                                                    </div>
                                                </div>
                                            </volist>
                                        </notempty>
                                        <php>$params = json_decode($vo['params'],true);</php>
                                        <notempty name="params">
                                            <fieldset class="layui-elem-field layui-field-title">
                                                <legend> PARAMS </legend>
                                            </fieldset>
                                            <table class="layui-table" lay-size="sm">
                                                <colgroup>
                                                    <col>
                                                    <col>
                                                    <col width="33.333%">
                                                    <col width="33.333%">
                                                </colgroup>
                                                <thead>
                                                    <tr>
                                                        <th>Key</th>
                                                        <th style="text-align: center;">类型</th>
                                                        <th>Value</th>
                                                        <th>Description</th>
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                    <volist name="params" id="v">
                                                        <tr>
                                                            <td>
                                                                <input type="text" value="{$v.key|default=''|raw}" placeholder="key" class="layui-input">
                                                            </td>
                                                            <td style="text-align: center;" class="code">{$v.type|default='text'}</td>
                                                            <td>
                                                                <input type="text" value="{$v.value|default=''|raw}" placeholder="value" class="layui-input">
                                                            </td>
                                                            <td>
                                                                <input type="text" value="{$v.description|default=''|highLight|raw}" placeholder="description" class="layui-input">
                                                            </td>
                                                        </tr>
                                                    </volist>
                                                </tbody>
                                            </table>
                                        </notempty>
                                        <neq name="vo.method" value="GET">
                                            <php>$formdata = json_decode($vo['formdata'],true);</php>
                                            <php>$urlencoded = json_decode($vo['urlencoded'],true);</php>
                                            <if $formdata ||$urlencoded ||$vo[ 'raw']>
                                                <fieldset class="layui-elem-field layui-field-title">
                                                    <legend> BODY</legend>
                                                </fieldset>
                                            </if>
                                            <notempty name="formdata">
                                                <p style="margin-top: 20px" class="code">form-data:</p>
                                                <table class="layui-table" lay-size="sm">
                                                    <colgroup>
                                                        <col>
                                                        <col>
                                                        <col width="33.333%">
                                                        <col width="33.333%">
                                                    </colgroup>
                                                    <thead>
                                                        <tr>
                                                            <th>Key</th>
                                                            <th style="text-align: center;">类型</th>
                                                            <th>Value</th>
                                                            <th>Description</th>
                                                        </tr>
                                                    </thead>
                                                    <tbody>
                                                        <volist name="formdata" id="v">
                                                            <tr>
                                                                <td>
                                                                    <input type="text" value="{$v.key|default=''|raw}" placeholder="key" class="layui-input">
                                                                </td>
                                                                <td style="text-align: center;" class="code">{$v.type|default='text'}</td>
                                                                <td>
                                                                    <input type="text" value="{$v.value|default=''|raw}" placeholder="value" class="layui-input">
                                                                </td>
                                                                <td>
                                                                    <input type="text" value="{$v.description|default=''|highLight|raw}" placeholder="description" class="layui-input">
                                                                </td>
                                                            </tr>
                                                        </volist>
                                                    </tbody>
                                                </table>
                                            </notempty>
                                            <notempty name="urlencoded">
                                                <p style="margin-top: 20px" class="code">x-www-form-urlencode:</p>
                                                <table class="layui-table" lay-size="sm">
                                                    <colgroup>
                                                        <col>
                                                        <col width="10">
                                                        <col width="33.333%">
                                                        <col width="33.333%">
                                                        <col>
                                                    </colgroup>
                                                    <thead>
                                                        <tr>
                                                            <th>Key</th>
                                                            <th style="text-align: center;">类型</th>
                                                            <th>Value</th>
                                                            <th>Description</th>
                                                        </tr>
                                                    </thead>
                                                    <tbody>
                                                        <volist name="urlencoded" id="v">
                                                            <tr>
                                                                <td>
                                                                    <input type="text" value="{$v.key|default=''}" placeholder="key" class="layui-input">
                                                                </td>
                                                                <td>{$v.type|default='text'}</td>
                                                                <td>
                                                                    <input type="text" value="{$v.value|default=''|raw}" placeholder="value" class="layui-input">
                                                                </td>
                                                                <td>
                                                                    <input type="text" value="{$v.description|default=''|highLight|raw}" placeholder="description" class="layui-input">
                                                                </td>
                                                            </tr>
                                                        </volist>
                                                    </tbody>
                                                </table>
                                            </notempty>
                                            <notempty name="vo.raw">
                                                <p style="margin-top: 20px" class="code">raw:</p>
                                                <div class="response" style="margin-top: 20px">
                                                    <pre class="code"></pre>
                                                    <textarea style="height: 1px;width: 1px;">
                                                        {$vo.raw|raw}
                                                    </textarea>
                                                </div>
                                            </notempty>
                                        </neq>
                                        <!-- 响应内容 -->
                                        <notempty name="vo.response">
                                            <fieldset class="layui-elem-field layui-field-title">
                                                <legend> EXAMPLE RESPONSE</legend>
                                            </fieldset>
                                            <div class="layui-tab" lay-filter="response" <if condition="session('user.id')==$user_id">lay-allowClose="true"</if> >
                                                <ul class="layui-tab-title">
                                                    <volist name="vo.response" id="v">
                                                        <li lay-id="{$v.id}" <eq name="i" value="1">class="layui-this"</eq> > {$v.name|highLight}
                                                            <span class="copy layui-badge layui-bg-black" data-clipboard-action="copy" data-clipboard-target="#res-{$v.id}">复制</span>
                                                            <if ($edit_auth) and ($is_self)>
                                                                &nbsp;
                                                                <span class="layui-badge-rim ajax-edit-api" data-url="{:url('response/edit',['id'=>$v['id']])}"> 编辑 </span>
                                                                <span class="layui-badge-rim ajax-set-api" data-url="{:url('response/delete',['id'=>$v['id']])}"> 删除 </span>
                                                            </if>
                                                        </li>
                                                    </volist>
                                                </ul>
                                                <div class="layui-tab-content">
                                                    <volist name="vo.response" id="v">
                                                        <div class="layui-tab-item <eq name='i' value='1'>layui-show</eq>">
                                                            <div class="response">
                                                                <pre class="code"></pre>
                                                                <textarea style="height: 1px;width: 1px;" id="res-{$v.id}"> {$v.body|default=''|raw}</textarea>
                                                            </div>
                                                            <notempty name="v.remark">
                                                                <blockquote class="layui-elem-quote">{$v.remark|highLight|raw}</blockquote>
                                                            </notempty>
                                                        </div>
                                                    </volist>
                                                </div>
                                            </div>
                                        </notempty>
                                    </div>
                                </div>
                            </div>
                        </volist>
                    </notempty>
                </volist>
            </notempty>
        </div>
    </div>
    <script type="text/javascript" src="__PUBLIC__/js/jquery-2.2.3.min.js"></script>
    <script src="__PUBLIC__/layui/layui.js"></script>
    <script type="application/javascript" src="__PUBLIC__/js/jquery.json-viewer.js"></script>
    <script type="application/javascript" src="__PUBLIC__/js/clipboard.min.js"></script>
    <script>
    var _pId = window._pId = '{$id|encrypt}'
    var is_login = 1;
    layui.config({
        base: '__PUBLIC__/mods/'
    }).use('edit');
    </script>
</body>

</html>